package com.dongdongshop.controller;

import com.dongdongshop.data.Result;
import com.dongdongshop.pojo.TbSeller;
import com.dongdongshop.service.SellerService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@RequestMapping("seller")
@Controller
public class SellerController {
    @DubboReference
    private SellerService sellerService;

    @RequestMapping("toSeller")
    public String toSeller(){
        return "admin/seller_1";
    }

    @RequestMapping("listSeller")
    @ResponseBody
    public Result listSeller(){
        try {
            List<TbSeller> list = sellerService.listSeller();
            return Result.OK().setData(list);
        }catch (Exception e){
            e.printStackTrace();
            return Result.ER();
        }
    }
    @RequestMapping("updateStatus")
    @ResponseBody
    public Result updateStatus(@RequestParam(value = "ids") List<String> ids ){
        try {
            sellerService.updateStatus(ids);
            return Result.OK();
        }catch (Exception e){
            e.printStackTrace();
            return Result.ER();
        }
    }
}
